package com.saxon.service.Blog;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saxon.Dao.Blog.BlogDao;
import com.saxon.pojo.Blog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class BlogServiceImpl implements BlogService {
    private BlogDao blogDao;

    @Autowired
    public void setBlogDao (BlogDao blogDao) {
        this.blogDao = blogDao;
    }

    @Override
    public List<Blog> QueryBlog (Map<String, Object> map) {
        return blogDao.QueryBlog (map);
    }

    @Override
    public List<Blog> QueryBlogNew () {
        return blogDao.QueryBlogNew ();
    }

    @Override
    public PageInfo<Blog> getAllTypeByPage (int pageNum, int pageSize, Map<String, Object> map) {
        PageHelper.startPage (pageNum, pageSize);
        List<Blog> blogs = blogDao.QueryBlog (map);
        return new PageInfo<> (blogs);
    }

    @Override
    public int QueryBlogNum (Map<String,Object> map) {
        return blogDao.QueryBlogNum (map);
    }

    @Override
    public List<Blog> queryBlogWithType (Map<String, Object> map) {
        return blogDao.queryBlogWithType (map);
    }
}
